package com.string.test;

import java.util.Scanner;
//定义一个字符串 实现字符串反转
public class Reverse {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入字符串：");
        String str = sc.next();
        String str2 = reverse(str);
        System.out.println(str2);
    }
    public static String reverse(String str){
        char[] arr=new char[str.length()];
        for (int i = 0; i < str.length(); i++) {
            arr[str.length()-i-1]=str.charAt(i);
        }
        String str2=new String(arr);
        return str2;
    }
}
